package edu.uic.ids517.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/*import javax.servlet.http.HttpSession;

import edu.uic.ids517.model.DatabaseAccessBean;*/

public class DatabaseAccessServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 

		System.out.println("DatabaseAccessServlet");
		String createTableUrl = "/createTable.jsp";
		String displayTableUrl = "/displayTable.jsp";
		String dropTableUrl = "/dropTable.jsp";
		String importTableUrl = "/importTable.jsp";
		String exportTableUrl = "/exportTable.jsp";		


		//HttpSession session = request.getSession();
		String action = request.getParameter("session"); 

		if(action.equalsIgnoreCase("CREATE TABLE"))
		{ 
			RequestDispatcher dispatcher = request.getRequestDispatcher(createTableUrl); 
			dispatcher.forward(request, response); 	
		}

		if(action.equalsIgnoreCase("DISPLAY TABLE"))
		{ 
			RequestDispatcher dispatcher = request.getRequestDispatcher(displayTableUrl); 
			dispatcher.forward(request, response); 	
		}

		if(action.equalsIgnoreCase("DROP TABLE"))
		{ 
			RequestDispatcher dispatcher = request.getRequestDispatcher(dropTableUrl); 
			dispatcher.forward(request, response); 	
		}

		if(action.equalsIgnoreCase("IMPORT TABLE"))
		{ 
			RequestDispatcher dispatcher = request.getRequestDispatcher(importTableUrl); 
			dispatcher.forward(request, response); 	
		}

		if(action.equalsIgnoreCase("EXPORT TABLE"))
		{ 
			RequestDispatcher dispatcher = request.getRequestDispatcher(exportTableUrl); 
			dispatcher.forward(request, response); 	
		}
	}
}

